package cd.cdyb.sms.dto;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author Junpeng.Su
 * @create 2017-07-15 下午 11:56
 * @description
 */
@Data
public class PageResult<T> implements Serializable {

    private static final long serialVersionUID = 8656597559014685635L;


    private List<T> data;    //结果集

    private long totalCount;        //总记录数

    private Integer pageNo;        //页码

    private Integer pageSize;        //分页大小

    private long totalPage;        //总页数

    public PageResult() {
    }

    public PageResult(Integer pageNo, Integer pageSize, List<T> data, long totalCount) {
        this.data = data;
        this.totalCount = totalCount;
        this.pageNo = pageNo;
        this.pageSize = pageSize;

        //计算总页数
        this.totalPage = (totalCount + pageSize - 1) / pageSize;

    }

    public PageResult(List<T> data, long totalCount) {
        this.data = data;
        this.totalCount = totalCount;
        this.pageNo = 1;
        this.pageSize = 10;
    }

}
